import { BASE_URL } from '../api/baseurl';

export async function fetchProtectedImage(fileName) {
  const token = localStorage.getItem('token');
  const response = await fetch(`${BASE_URL}/api/Image/file/${fileName}`, {
    headers: {
      Authorization: `Bearer ${token}`
    }
  });
  if (!response.ok) throw new Error('图片获取失败');
  const blob = await response.blob();
  return URL.createObjectURL(blob);
} 